package com.test.mylotterysystem.comment.utils;

import com.test.mylotterysystem.comment.errorCode.ControllerErrorCode;
import com.test.mylotterysystem.comment.exception.ControllerException;
import com.test.mylotterysystem.controller.Result.UserLoginResult;
import com.test.mylotterysystem.controller.Result.UserRegisterResult;
import com.test.mylotterysystem.service.DTO.UserLoginDTO;
import com.test.mylotterysystem.service.DTO.UserRegisterDTO;
import org.springframework.beans.BeanUtils;

public class MyBeanUtil {
    public static UserRegisterResult transOfUserRegisterResult(UserRegisterDTO userRegisterDTO) {
        if (userRegisterDTO == null) {
            throw new ControllerException(ControllerErrorCode.TRANS_IS_ERROR);
        }
        UserRegisterResult userRegisterResult = new UserRegisterResult();
        BeanUtils.copyProperties(userRegisterDTO, userRegisterResult);
        return userRegisterResult;
    }

    public static UserLoginResult transOfUserLoginResult(UserLoginDTO userLoginDTO) {
        if (userLoginDTO == null) {
            throw new ControllerException(ControllerErrorCode.TRANS_IS_ERROR);
        }
        UserLoginResult userLoginResult = new UserLoginResult();
        BeanUtils.copyProperties(userLoginDTO,userLoginResult);
        return userLoginResult;
    }
}
